﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Web.Security;

public partial class Admin_Sentence : System.Web.UI.Page
{
    protected void LogoutButton_Click(object sender, EventArgs e)
    {
        Session.Abandon();
        FormsAuthentication.SignOut();
        Response.Redirect("~/Default.aspx");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string filePath = Server.MapPath("~\\Files\\SentenceFile.txt");
            if (!File.Exists(filePath))
            {
                File.Create(filePath);
            }
            StreamReader streamReader = new StreamReader(filePath);
            SentenceTextBox.Text = streamReader.ReadToEnd();
            streamReader.Close();
            streamReader.Dispose();
        }
    }
    protected void UpdateButton_Click(object sender, ImageClickEventArgs e)
    {
        string filePath = Server.MapPath("~\\Files\\SentenceFile.txt");
        if (File.Exists(filePath))
        {
            FileInfo file = new FileInfo(filePath);
            file.IsReadOnly = false;
            TextWriter textWriter = new StreamWriter(filePath);
            textWriter.WriteLine(SentenceTextBox.Text);
            textWriter.Close();
        }
    }
}